<template>
  <a-card :bordered="false">
    <div class="table-page-search-wrapper">
      <a-form layout="inline">
        <a-row :gutter="48">

          <a-col :md="8" :sm="24">
            <a-form-item label="入库单号">
              <a-input v-model="queryParam.orderNumber" placeholder="请输入入库单号"/>
            </a-form-item>
          </a-col>

          <a-col :md="!advanced && 8 || 24" :sm="24">
            <span class="table-page-search-submitButtons" :style="advanced && { float: 'right', overflow: 'hidden' } || {} ">
              <a-button type="primary" @click="$refs.table.refresh(true)">查询</a-button>
              <!--<a-button style="margin-left: 8px" @click="() => queryParam = {}">重置</a-button>-->
            </span>
          </a-col>

          <!-- <a-col :md="24" :sm="24">
            <a-form-item label="归属公司：">
              <FCOrgRadioGroup v-model="queryParam.orgId"
                               :filter-types="[$businessEnum.ORG_TYPE_ENUM.COMPANY.id]"/>
            </a-form-item>
          </a-col> -->

        </a-row>
      </a-form>
    </div>

    <s-table
      ref="table"
      size="default"
      :columns="columns"
      :data="loadData"
      :alert="true"
      :rowKey="(record) => record.code"
      :rowSelection="null"
    >

      <span slot="action" slot-scope="text, record">
          <a @click="$refs.detailForm.show(record)">详情</a>
      </span>
    </s-table>

    <!--  订单详情  -->
    <detail-form ref="detailForm" @ok="handleOk"/>

  </a-card>
</template>

<script>
import {STable} from '@/components'
import {page} from '@/api/modular/main/emsorder/emsOrderManage'

import detailForm from '@/views/main/materialManagement/simpleOutOrder/detailForm'
import FCOrgRadioGroup from '@/components/FcOrgRadioGroup/FCOrgRadioGroup'

export default {
  components: {
    FCOrgRadioGroup,
    STable,
    detailForm,
  },
  data() {
    return {
      advanced: false, // 高级搜索 展开/关闭
      queryParam: {},  // 查询参数
      columns: [       // 表头
        {
          title: '入库单号',
          dataIndex: 'orderNumber'
        },
        {
          title: '入库时间',
          dataIndex: 'createTime'
        },
        {
          title: '操作人',
          dataIndex: 'createUserName',
        },
        {
          title: '备注',
          dataIndex: 'remark'
        },
        {
          title: '操作',
          dataIndex: 'action',
          width: '150px',
          scopedSlots: {customRender: 'action'}
        }
      ],
      // 加载数据方法 必须为 Promise 对象
      loadData: parameter => {
        this.queryParam.orderType = this.$businessEnum.ORDER_TYPE_ENUM.inOrder.id
        this.queryParam.materialType = this.$businessEnum.MATERIAL_TYPE_ENUM.overseasProduct.id
        return page(Object.assign(parameter, this.queryParam)).then((res) => {
          return res.data
        })
      },
      scheduleProductionVisible: false,
      selectedRowKeys: [],
      selectedRows: [],
      defaultExpandedKeys: [],
      replaceFields: {
        key: 'id',
      },
      urlParam: {},
      columnsType: '',
      suppliers: [],
      orgs: [],
      viewState: '',
      materialType: '',
    }
  },
  methods: {
    toggleAdvanced() {
      this.advanced = !this.advanced
    },
    handleOk() {
      this.$refs.table.refresh()
    },
    onSelectChange(selectedRowKeys, selectedRows) {
      this.selectedRowKeys = selectedRowKeys
      this.selectedRows = selectedRows
    },
  }
}
</script>

<style lang="less">
.table-operator {
  margin-bottom: 18px;
}

button {
  margin-right: 8px;
}
</style>
